﻿using System;
using System.Globalization;
using System.Windows.Forms;

namespace toNyxPhysRanger
{
    public partial class CrSettingsForm : Form
    {
        public CrSettingsForm()
        {
            InitializeComponent();
        }

        #region Load/Close

        private void CrSettingsFormLoad(object sender, EventArgs e)
        {

            #region Flasks Data

            // life/mana flasks
            txt_lifeflasktr.Text = toNyxPhysRanger.MyFlasksSettings.LifeFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            txt_manaflasktr.Text = toNyxPhysRanger.MyFlasksSettings.ManaFlaskThreshold.ToString(CultureInfo.InvariantCulture);

            // special flasks
            cb_EnableGranite.Checked = toNyxPhysRanger.MyFlasksSettings.UseGraniteFlask;
            txt_graniteFlaskTr.Text = toNyxPhysRanger.MyFlasksSettings.GraniteFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableJade.Checked = toNyxPhysRanger.MyFlasksSettings.UseJadeFlask;
            txt_jadeflasktr.Text = toNyxPhysRanger.MyFlasksSettings.JadeFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableRuby.Checked = toNyxPhysRanger.MyFlasksSettings.UseRubyFlask;
            txt_rubyflasktr.Text = toNyxPhysRanger.MyFlasksSettings.RubyFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableDiamond.Checked = toNyxPhysRanger.MyFlasksSettings.UseDiamondFlask;
            txt_diamondflasktr.Text = toNyxPhysRanger.MyFlasksSettings.DiamondFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableBleeding.Checked = toNyxPhysRanger.MyFlasksSettings.UseBleedingFlask;
            txt_bleedingflasktr.Text = toNyxPhysRanger.MyFlasksSettings.BleedingFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableShock.Checked = toNyxPhysRanger.MyFlasksSettings.UseShockFlask;
            txt_shockflasktr.Text = toNyxPhysRanger.MyFlasksSettings.ShockFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableBurning.Checked = toNyxPhysRanger.MyFlasksSettings.UseBurningFlask;
            txt_burningflasktr.Text = toNyxPhysRanger.MyFlasksSettings.BurningFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableFrozen.Checked = toNyxPhysRanger.MyFlasksSettings.UseFrozenFlask;
            txt_frozenflasktr.Text = toNyxPhysRanger.MyFlasksSettings.FrozenFlaskThreshold.ToString(CultureInfo.InvariantCulture);
            cb_EnableDivination.Checked = toNyxPhysRanger.MyFlasksSettings.UseDivinationFlask;
            txt_divinationflasktr.Text = toNyxPhysRanger.MyFlasksSettings.DivinationFlaskThreshold.ToString(CultureInfo.InvariantCulture);

            #endregion

            #region Spells

            cb_UseCriticalWeakness.Checked = toNyxPhysRanger.MyAbilitySettings.UseCriticalWeakness;
            rb_UseRoA.Checked = toNyxPhysRanger.MyAbilitySettings.UseRainOfArrows;
            rb_UseSplitArrow.Checked = toNyxPhysRanger.MyAbilitySettings.UseSplitArrow;
            txt_AoeTargetsAmount.Text = toNyxPhysRanger.MyAbilitySettings.AoETargetsAmount.ToString(CultureInfo.InvariantCulture);

            #endregion
        }

        private void CrSettingsFormClosing(object sender, EventArgs e)
        {
            #region Flasks Data

            // life/mana flasks
            toNyxPhysRanger.MyFlasksSettings.LifeFlaskThreshold = Convert.ToInt32(txt_lifeflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.ManaFlaskThreshold = Convert.ToInt32(txt_manaflasktr.Text);

            // special flasks
            toNyxPhysRanger.MyFlasksSettings.UseGraniteFlask = cb_EnableGranite.Checked;
            toNyxPhysRanger.MyFlasksSettings.GraniteFlaskThreshold = Convert.ToInt32(txt_graniteFlaskTr.Text) ;
            toNyxPhysRanger.MyFlasksSettings.UseJadeFlask = cb_EnableJade.Checked;
            toNyxPhysRanger.MyFlasksSettings.JadeFlaskThreshold = Convert.ToInt32(txt_jadeflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseRubyFlask = cb_EnableRuby.Checked;
            toNyxPhysRanger.MyFlasksSettings.RubyFlaskThreshold = Convert.ToInt32(txt_rubyflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseDiamondFlask = cb_EnableDiamond.Checked;
            toNyxPhysRanger.MyFlasksSettings.DiamondFlaskThreshold = Convert.ToInt32(txt_diamondflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseBleedingFlask = cb_EnableBleeding.Checked;
            toNyxPhysRanger.MyFlasksSettings.BleedingFlaskThreshold = Convert.ToInt32(txt_bleedingflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseShockFlask = cb_EnableShock.Checked;
            toNyxPhysRanger.MyFlasksSettings.ShockFlaskThreshold = Convert.ToInt32(txt_shockflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseBurningFlask = cb_EnableBurning.Checked;
            toNyxPhysRanger.MyFlasksSettings.BurningFlaskThreshold = Convert.ToInt32(txt_burningflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseFrozenFlask = cb_EnableFrozen.Checked;
            toNyxPhysRanger.MyFlasksSettings.FrozenFlaskThreshold = Convert.ToInt32(txt_frozenflasktr.Text);
            toNyxPhysRanger.MyFlasksSettings.UseDivinationFlask = cb_EnableDivination.Checked;
            toNyxPhysRanger.MyFlasksSettings.DivinationFlaskThreshold = Convert.ToInt32(txt_divinationflasktr.Text);

            #endregion

            #region Spells

            toNyxPhysRanger.MyAbilitySettings.UseCriticalWeakness = cb_UseCriticalWeakness.Checked;
            toNyxPhysRanger.MyAbilitySettings.UseRainOfArrows = rb_UseRoA.Checked;
            toNyxPhysRanger.MyAbilitySettings.UseSplitArrow = rb_UseSplitArrow.Checked;
            toNyxPhysRanger.MyAbilitySettings.AoETargetsAmount = Convert.ToInt32(txt_AoeTargetsAmount.Text);

            #endregion

            // Save Data
            toNyxPhysRanger.MyFlasksSettings.SaveFlasksData();
            toNyxPhysRanger.MyAbilitySettings.SaveAbilitiesData();
        }

        #endregion

        #region CheckBoxes

        private void CbEnableGraniteCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseGraniteFlask = cb_EnableGranite.Checked;
        }

        private void CbEnableJadeCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseJadeFlask = cb_EnableJade.Checked;
        }

        private void CbEnableRubyCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseRubyFlask = cb_EnableRuby.Checked;
        }

        private void CbEnableDiamondCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseDiamondFlask = cb_EnableDiamond.Checked;
        }

        private void CbEnableBleedingCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseBleedingFlask = cb_EnableBleeding.Checked;
        }

        private void CbEnableShockCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseShockFlask = cb_EnableShock.Checked;
        }

        private void CbEnableBurningCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseBurningFlask = cb_EnableBurning.Checked;
        }

        private void CbEnableFrozenCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseFrozenFlask = cb_EnableFrozen.Checked;
        }

        private void CbEnableDivinationCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyFlasksSettings.UseDivinationFlask = cb_EnableDivination.Checked;
        }

        private void CbUseCriticalWeaknessCheckedChanged(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyAbilitySettings.UseCriticalWeakness = cb_UseCriticalWeakness.Checked;
        }

        #endregion

        private void RbAoeChoice(object sender, EventArgs e)
        {
            toNyxPhysRanger.MyAbilitySettings.UseRainOfArrows = rb_UseRoA.Checked;
            toNyxPhysRanger.MyAbilitySettings.UseSplitArrow = rb_UseSplitArrow.Checked;
        }

    }
}
